//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package mutsumimod.actions;

import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.MakeTempCardInHandAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import mutsumimod.cards.derivative.CurseImagination;
import mutsumimod.cards.copy.Imagination;

public class NoNeedMoreAction extends AbstractGameAction {

    private boolean upgraded;

    public NoNeedMoreAction(boolean upgraded) {
        this.upgraded = upgraded;
    }

    public void update() {
        for (int i=AbstractDungeon.player.hand.group.size() - 1; i >= 0; i--) {
            AbstractCard origin=AbstractDungeon.player.hand.group.get(i);
            if(origin.type.equals(AbstractCard.CardType.CURSE)||origin.type.equals(AbstractCard.CardType.STATUS)){
                addToTop(new MakeTempCardInHandAction(new CurseImagination()));
            }else{
                Imagination card=new Imagination(origin.rarity);
                if(upgraded) {
                    card.upgrade();
                }
                if(!isNormalRarity(card)) {
                    card.rarity = AbstractCard.CardRarity.COMMON;
                }
                addToTop(new MakeTempCardInHandAction(card));
            }


        }
        for(int i=AbstractDungeon.player.hand.group.size() - 1; i >= 0; i--) {
            addToTop(new BetterExhaustSpecificCardAction(AbstractDungeon.player.hand.group.get(i)));
        }
        isDone = true;
    }

    public boolean isNormalRarity(AbstractCard card) {
        return card.rarity.equals(AbstractCard.CardRarity.COMMON)||card.rarity.equals(AbstractCard.CardRarity.UNCOMMON)
                ||card.rarity.equals(AbstractCard.CardRarity.RARE);
    }
}
